package com.faith.dynamic.enums;

import lombok.Getter;

/**
 * @ClassName FaithSysExceptionEnum$
 * @Description 异常枚举
 * @Author faith$
 * @Date
 * @Version 1.0
 **/
@Getter
public enum FaithSysExceptionEnum {
    NO_PRIVILEGE("401", "无权限访问接口"),
    NO_ACCESS("401", "禁止访问"),

    INTERNAL_ERROR("500", "系统内部异常"),
    ILLEGAL_PARAM("501", "请求参数不合法"),
    NO_LOGIN("502", "请先登录"),
    ONLY_HTTPS("503", "只支持HTTPS访问"),
    REPEAT_REQUEST("504", "重复的操作"),
    ILLEGAL_OPRATION("505","操作已达上限"),

    QUERY_TASK_LIST_ERROR("506","查询定时任务列表异常"),
    ADD_TASK_ERROR("507","添加定时任务异常"),
    UPDATE_TASK_ERROR("508","更新定时任务异常"),
    CANCEL_TASK_ERROR("509","取消定时任务异常")
    ;
    private String code;
    private String message;

    FaithSysExceptionEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static FaithSysExceptionEnum get(Long code) {
        if(code == null) {
            return null;
        } else {
            FaithSysExceptionEnum[] arr$ = values();
            int len$ = arr$.length;

            for(int i$ = 0; i$ < len$; ++i$) {
                FaithSysExceptionEnum appResultCodeEnum = arr$[i$];
                if(appResultCodeEnum.getCode().equals(code)) {
                    return appResultCodeEnum;
                }
            }

            return null;
        }
    }

    public static boolean is(FaithSysExceptionEnum resultCodeEnum, Long code) {
        return (resultCodeEnum != null && code != null) && resultCodeEnum.getCode().equals(code);
    }
}
